<?php
include_once("../include/init.php");
	//判断用户登录
	if(!isset($_SESSION['user'])){
		msg("请先登录","login.php");
		exit;
	}
	//获取用户id
$uid =$_SESSION['uid'];
//订单数据库处理
$sql = "select * from tr_order where user_id =$uid ";
$res = mysql_query($sql);
$info = [];
if(mysql_num_rows($res)>0){
	while($list = mysql_fetch_assoc($res)){
		$info[] =$list;
	}
}
foreach($info as $vo){
 $goods = $vo['order_goods'];
 $cart = unserialize($goods);
}
?>
<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>首页</title>
	<link rel="stylesheet" href="../public/css/index.css" />
	<link rel="stylesheet" href="../public/css/order_list.css">
</style>
	</head>
	<body>
		<!-- 头部-->
<?php
include_once("header.php");
?>
		<!-- 主体-->
		<div class="main">
			<table border=1 cellspacing="0" cellpadding="0"width="1000px"height=100px >
				<th>订单序列号</th>
				<th>订单编号</th>
				<th>订单信息</th>
				<th>订单价格</th>
				<th>订单时间</th>
				<th>订单状态</th>
				<th>操作</th>
				<th>评价</th>
				<?php foreach ($info as $key => $value): ?>		
				<tr align="center">
					<td><?=$value['order_id']?></td>
					<td><?=$value['order_sn']?></td>
					<td>
					<?php
					 $goods = $value['order_goods'];
 					$cart = unserialize($goods);
 						 foreach($cart as $v){
 							echo $v['pname'].$v['size'];
 						}
					?>
					</td>
					<td><span>￥</span><?=$value['order_amount']?>.00</td>
					<td><?=date("Y-m-d H:i:s",$value['add_time'])?></td>
					<td>
						<?php
							if($value['order_status']==0){
								echo "未付款";
							}elseif($value['order_status']==1){
								echo"已付款";
							}elseif($value['order_status']==2){
								echo"未发货";
							}
							elseif($value['order_status']==3){
								echo"已发货";
							}elseif($value['order_status']==4){
								echo"已收货";
							}
						?>
					</td>
					<td>
						<a href="del_order.php?oid=<?=$value['order_id']?>">删除</a>
				   		<a href="editorder.php?oid=<?=$value['order_id']?>">去付款</a><br>
				   		<?php
				   			$id=$value['order_id'];
				   			if($value['order_status']==1){
				   				echo"待发货";
				   			}elseif($value['order_status']==3){

				   				echo "<a href='succeed.php?id=$id'>"."确认收货"."</a>";
				   			}
				   		?>	
					</td>
					<td><a href='comment.php?oid=
						<?=$value['order_id']?>&pid=<?=$v['pid']?>
					'>评价</a></td>
				</tr>	
				<?php endforeach ?>
			</table>
		</div>
			<hr>
		<div class="clearfix"></div>
			<!-- 页脚-->
			<?php
             include_once("footer.php");
             ?>
		
	</body>
</html>
